import {createRouter, createWebHashHistory,createWebHistory} from 'vue-router'
import HomeView from '@/views/HomeView.vue'
import SearchView from '@/views/SearchView.vue'
import NotFindView from '@/views/NotFindView.vue'
import MyView from '@/views/MyView.vue'

const routes = [
  {path: '/home', component: HomeView},
  {path: '/search/:words?',name:"search", component: SearchView},
  {path: '/my', name: 'my', component: MyView},
  { path: '/:pathMatch(.*)*', name: 'NotFindView', component: NotFindView } //最后一个
  // { path: '/', redirect: '/home' },
  // { path: '/home', name: 'home', component: () => import('@/views/HomeView.vue') },
  // { path: '/my', name: 'my', component: () => import('@/views/MyView.vue') },
  // // /:words 必须要传递
  // // /:words? 参数可选，不写也可以
  // { path: '/search/:words?', name: 'search', component: () => import('@/views/SearchView.vue') },
  // { path: '/:pathMatch(.*)*', name: 'NotFound', component: () => import('@/views/NotFindView.vue') }
]

const router = createRouter({
  history: createWebHistory(),  // history模式
  routes
})

export default router